package xc.service;

import xc.dao.ProgramDao;
import xc.entity.Program;

import java.sql.SQLException;

public class ProgramService {


    public static boolean addProgram(Program program) throws SQLException {
        if (ProgramDao.existProgram(program.getPName())) {
            System.out.println("项目已存在");
            return false;
        }else {
            ProgramDao.addProgram(program);
            System.out.println("项目已添加");
            return true;
        }
    }

    public static boolean deleteProgram(String programName) throws SQLException {
        if (!ProgramDao.existProgram(programName)) {
            System.out.println("项目不存在");
            return false;
        }else {
            ProgramDao.deleteProgram(programName);
            return true;
        }
    }

    public static boolean updateProgram(Program program) throws SQLException {
        if (!ProgramDao.existProgram(program)) {
            System.out.println("项目不存在");
            return false;
        }else {
            ProgramDao.updateProgram(program);
            return true;
        }
    }

    public static void selectProgram() throws SQLException {
        ProgramDao.selectProgram();
    }

}
